﻿using System;
using System.Text;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WCSFContrib.ECommerceCatalog.BusinessEntities;
using WCSFContrib.ECommerceCatalog.Product.Views;
using WCSFContrib.ECommerceCatalog.Product.Tests.Mocks;

namespace WCSFContrib.ECommerceCatalog.Product.Tests
{
    /// <summary>
    /// Summary description for ProductDetailsPresenterTestFixture
    /// </summary>
    [TestClass]
    public class ProductDetailsPresenterTestFixture
    {
        private MockProductDetailsView _view;

        public ProductDetailsPresenterTestFixture()
        {
        }

        [TestMethod]
        public void ShouldShowProductDetails()
        {
            ProductDetailsPresenter presenter = GetDefaultPresenterInitialized();

            presenter.OnShowProductDetails(new Item());

            Assert.IsTrue(_view.ItemIdCalled);
            Assert.IsTrue(_view.ItemImageCalled);
            Assert.IsTrue(_view.ItemNameCalled);
            Assert.IsTrue(_view.ItemPriceCalled);
            Assert.IsTrue(_view.ItemQuantityCalled);
            Assert.IsTrue(_view.ItemCategoryCalled);
            Assert.IsTrue(_view.ItemDescriptionCalled);
        }

        private ProductDetailsPresenter GetDefaultPresenterInitialized()
        {
            _view = new MockProductDetailsView();
            ProductDetailsPresenter presenter = new ProductDetailsPresenter();
            presenter.View = _view;

            return presenter;
        }
    }

    class MockProductDetailsView : IProductDetailsView
    {
        public bool ItemIdCalled = false;
        public bool ItemImageCalled = false;
        public bool ItemNameCalled = false;
        public bool ItemPriceCalled = false;
        public bool ItemQuantityCalled = false;
        public bool ItemCategoryCalled = false;
        public bool ItemDescriptionCalled = false;

        #region IProductDetailsView Members

        public void ShowProductDetails(Item item)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        public int ItemId
        {
            get { throw new Exception("The method or operation is not implemented."); }
            set { ItemIdCalled = true; }
        }

        public string ItemImage
        {
            set { ItemImageCalled = true; }
        }

        public string ItemName
        {
            set { ItemNameCalled = true; }
        }

        public double ItemPrice
        {
            set { ItemPriceCalled = true; }
        }

        public int ItemQuantity
        {
            get { throw new Exception("The method or operation is not implemented."); }
            set { ItemQuantityCalled = true; }
        }

        public Category ItemCategory
        {
            set { ItemCategoryCalled = true; }
        }

        public string ItemDescription
        {
            set { ItemDescriptionCalled = true; }
        }

        #endregion
    }
}

